//
//  SNOrderFormDetailBasicModel.m
//  app
//
//  Created by 王少宁 on 15/5/7.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//  配送时间,发票信息,买家留言 model

#import "SNOrderFormDetailBasicModel.h"

@implementation SNOrderFormDetailBasicModel

- (instancetype)initWithDict:(NSDictionary *)dict
{
    if ([super init]) {
        _expressStr = @"支付配送";
        _invoiceStr = @"发票信息";
        _buyerWordsStr = @"买家留言";
        
#warning 支付方式还没有确定,这个参数可能需要修改
        if (dict[@"paytype"] == 0) {
            _paytype = @"在线支付";
        } else {
            _paytype = @"";
        }
        
        NSDictionary * express_info = dict[@"express_info"];
        if ([express_info allKeys].count) {//快递信息，如果还没有联系上，这就是一个空对象 {}
            _express_habit = express_info[@"express_habit"];//具体的配送时间
            
            if ([_express_habit isEqualToString:@"只在工作日送货"]) {
                _dispathType = HZOrderDispatchTypeWeekday;
            } else if ([_express_habit isEqualToString:@"只在周末送货"]) {
                _dispathType = HZOrderDispatchTypeWeekend;
            } else if ([_express_habit isEqualToString:@"工作日和周末都可以送货"]) {
                _dispathType = HZOrderDispatchTypeWholeWeek;
            } else {
//                _express_habit = @"无";
                _dispathType = HZOrderDispatchTypeNone;
            }
        }
        
        NSDictionary * invoice_info = dict[@"invoice_info"];
        if ([invoice_info allKeys].count) {//发票信息，如果不需要发票，这里就是一个空对象，{}
            _invoice_name = invoice_info[@"invoice_name"];
            _invoice_type = invoice_info[@"invoice_type"];
        } else {
            _invoice_name = @"无";
        }
        
        if ([dict[@"notes"] isEqualToString:@""]) {
            _notes = @"无";
        } else {
            _notes = dict[@"notes"];
        }
    }
    return self;
}

+ (instancetype)modelWithDict:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

@end
